package com.bulls.demo.hrmsdemo.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.bulls.demo.hrmsdemo.form.LoginForm;
import com.bulls.demo.hrmsdemo.service.LoginService;



public class LoginAction extends Action{
	public ActionForward execute(ActionMapping actionMapping,ActionForm actionForm,
								 HttpServletRequest request,HttpServletResponse response)
	throws Exception{
		System.out.println("action------------>");
		String forwardName = "failure";
		LoginForm form = (LoginForm)actionForm;
		boolean boo = false;
		System.out.println("action------------>");
		boo = getLoginService().isValidUser(form.getUserName(), form.getPassword());
		System.out.println("boooooooooooo--------->"+boo);
		if(boo){
			forwardName = "success";
		}
		return actionMapping.findForward(forwardName);
	}
	
	public LoginService getLoginService(){
		LoginService loginService = new LoginService();
		return loginService;
	}
}
